﻿using System.Collections.Generic;
using Assets.Scripts.Net.Data;
using Assets.Scripts.Net.Data.Model;
using Assets.Scripts.UI.Item;
using UnityEngine;
using UnityEngine.UI;

namespace Assets.Scripts.UI.Panel
{
    /// <summary>
    /// 模拟考试
    /// </summary>
    public class MockExamPanel : UIBase<MockExamPanel>
    {

        public Transform Content_Paper;//试卷
        public Transform Content_Course;//课程
        public Button ExitButton;
        public Button SettingButton;

        public CourseItem NowClickItem { get; set; }//当前点击的item

        public static MockExamPanel _Instance;

        protected override void InitOnDestroy()
        {
            _Instance = null;
        }


        protected override void InitOnAwake()
        {
            _Instance = this;
            AutoFindComponent(transform,true);
            ExitButton.onClick.AddListener(Exit);
            SettingButton.onClick.AddListener(() => { CreatePanel(PanelType.SettingPanel); });
        }

        protected override UIType UIType
        {
            get { return UIType.Panel;}
        }

        /// <summary>
        /// 初始化信息
        /// </summary>
        public void Init(List<CourseInfo> courseInfos)
        {
            for (int i = 0; i < courseInfos.Count; i++)
            {
                Transform tsf = CreateItem(ItemType.CourseItem);
                tsf.SetParent(Content_Course);
                tsf.localPosition=Vector3.zero;
                tsf.localScale=Vector3.one;
                CourseItem item= tsf.GetComponent<CourseItem>();
                item.Init(courseInfos[i], NetConstValue.Mock_CourseInfo, new[] {Content_Paper});
                if(i==0)item.CourseButton.onClick.Invoke();
            }
        }
    }
}
